home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
listhelp.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
41KB
|
1,278 lines
IMPLEMENTATION MODULE ListHelp;
(*==============================================================*
* Modul: Modul zur Verwaltung der Abrufboxen *
* Autor: Dirk Steins, Jo Gttker-Schnetmann *
* erstellt am: 10.04.1992 *
* letzte nderung am: 10.04.1992 *
* Version: 1.0 *
* Interne Version: V#0001 *
*==============================================================*
*----------------------------------------------------------------------------
* Datum Vers. Autor nderung (Arbeitsbericht)
*----------------------------------------------------------------------------
*----------------------------------------------------------------------------
*)
FROM SYSTEM IMPORT ADDRESS, TSIZE, ADR, CADR, CAST, ASSEMBLER, CALLSYS;
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
IMPORT Lists;
IMPORT Strings;
IMPORT StrConv;
IMPORT GrafBase;
IMPORT BinOps;
FROM Void IMPORT v;
FROM ListDl IMPORT doListDial, specialButHdler, dummyInLoop, inLoopProc, ldElems;
IMPORT ListDl;
FROM VDIUtil IMPORT FormHandle;
IMPORT data;
IMPORT dataSys;
IMPORT MausTauschrsc;
IMPORT MTE;
IMPORT GroupSelect;
IMPORT ListMan;
IMPORT CatGlobal;
IMPORT ConfVars;
IMPORT Varnames;
IMPORT CatHelp;
IMPORT MagicAES;
IMPORT MagicDOS;
IMPORT MagicStrings;
IMPORT mtAppl;
IMPORT mtDials;
IMPORT mtAlerts;
IMPORT mtUtils;
IMPORT WinDials;
VAR gruppen, adr : ADDRESS;
VAR lastGroup : ARRAY [0..255] OF CHAR;
globalLength : INTEGER;
groupDialIsOpen: BOOLEAN;
nameDialIsOpen : BOOLEAN;
(*------------------------------------------------------------------------*)
TYPE envRecord = RECORD
mode: groupSelectMode;
isReadMode: BOOLEAN;
exitBut : INTEGER;
END;
envRecPtr = POINTER TO envRecord;
VAR grList : Lists.List;
clipEntry : GroupSelect.groupPtr;
PROCEDURE selGrEntry (entry, env : ADDRESS; line : INTEGER): BOOLEAN;
VAR gr : GroupSelect.groupPtr;
str: ARRAY [0..255] OF CHAR;
BEGIN
gr := entry;
IF gr = NIL THEN RETURN FALSE END;
gr^.selected := ~gr^.selected;
IF gr^.selected & (line >= 0) THEN
mtUtils.SetObjcString (gruppen, MausTauschrsc.newgroup, gr^.name^);
WinDials.WinDialDraw (gruppen, MausTauschrsc.newgroup, 0, v.r, FALSE);
END;
RETURN FALSE
END selGrEntry;
PROCEDURE groupToStr (entry, env : ADDRESS; VAR str : ARRAY OF CHAR);
VAR gr : GroupSelect.groupPtr;
BEGIN
gr := entry;
IF gr = NIL THEN RETURN END;
MagicStrings.Assign (gr^.name^,str);
END groupToStr;
PROCEDURE buildGroup (entry, env : ADDRESS; VAR str : ARRAY OF CHAR);
VAR gr : GroupSelect.groupPtr;
newIdx,
lastIdx,
unrd,
new : CARDINAL;
numStr, unread : ARRAY [0..4] OF CHAR;
modePtr : envRecPtr;
PROCEDURE card2str(new : CARDINAL; VAR numStr : ARRAY OF CHAR);
VAR appendK : BOOLEAN;
theStr : ARRAY [0..1024] OF CHAR;
i,j : CARDINAL;
BEGIN
IF new # 0
THEN
appendK := FALSE;
IF new > 999 THEN
new := new DIV 1000;
appendK := TRUE;
END;
MagicStrings.Assign(StrConv.CardToStr (new, 3), theStr);
IF appendK
THEN
MagicStrings.Delete (theStr, 0, 1);
MagicStrings.Append ("K", theStr);
END;
i := 0;
j := 1;
REPEAT
numStr[j] := theStr[i];
INC(i);
INC(j);
UNTIL (theStr[i] = 0C) OR (j >= HIGH(numStr));
(*
IF new > 99 THEN
numStr[1] := CHR(ORD('0') + CARDINAL(new DIV 100));
END;
IF new > 9 THEN
numStr[2] := CHR(ORD('0') + CARDINAL((new MOD 100) DIV 10));
END;
numStr[3] := CHR(ORD('0') + CARDINAL(new MOD 10));
*)
END;
END card2str;
BEGIN
gr := GroupSelect.groupPtr (entry);
modePtr := env;
MagicStrings.Assign (gr^.name^,str);
(* Anzahl der neuen Nachrichten suchen *)
IF modePtr^.isReadMode
THEN
newIdx := data.FirstNewMsg (gr^.catNumber);
lastIdx := data.LastMsgOfGroup (gr^.catNumber);
IF (lastIdx # dataSys.empty) & (newIdx # dataSys.empty) & (newIdx <= lastIdx) THEN new := lastIdx - newIdx+1;
ELSE new := 0
END;
MagicStrings.Assign (' ', numStr);
card2str(new, numStr);
unrd := data.unreadMsgCount(gr^.catNumber);
IF unrd = 0FFFFH THEN unrd := 0 END;
MagicStrings.Assign (' ', unread);
card2str(unrd, unread);
(* Jetzt noch Lngenanpassung *)
IF LENGTH (str) < 40 THEN (* YYY hier noch irgendwas sinnvolles einsetzen, das die Lnge rausfindet! *)
MagicStrings.Append (Strings.Space (40 (* 39 *) -LENGTH(str)), str);
ELSE
MagicStrings.Append (' ', str);
END;
MagicStrings.Append (unread, str);
IF (new # 0 ) & (unrd # 0) THEN
MagicStrings.Append ('|', str);
ELSE
MagicStrings.Append (' ', str);
END;
MagicStrings.Append (numStr, str);
END;
globalLength := BinOps.HigherInt (globalLength, LENGTH (str)+2);
END buildGroup;
(*$Z-*)
PROCEDURE findSel (e, i : ADDRESS): BOOLEAN;
VAR entry : GroupSelect.groupPtr;
BEGIN
entry := e;
RETURN entry^.selected;
END findSel;
(*$Z+*)
PROCEDURE cutEntry (obj: INTEGER; env, info : ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
VAR r : GrafBase.Rectangle;
found : BOOLEAN;
listInfo : ListMan.LISTINFO;
BEGIN
(* Selektierten Eintrag in der Liste finden und aus der Liste entfernen *)
Lists.ResetList (grList);
Lists.ScanEntries (grList, Lists.forward, findSel, NIL, found);
IF found THEN
clipEntry := Lists.CurrentEntry (grList);
Lists.RemoveEntry (grList, v.bool);
listInfo := ListMan.LISTINFO (info);
ListMan.ListScroll2Selection (listInfo, TRUE);
(* Nun das neue Icon darstellen *)
mtUtils.SetFlag (gruppen, MausTauschrsc.grcfull, MagicAES.HIDETREE, FALSE);
mtUtils.SetFlag (gruppen, MausTauschrsc.grcempty, MagicAES.HIDETREE, TRUE);
mtUtils.CalcArea (gruppen, MausTauschrsc.grcfull, r);
WinDials.WinDialDraw (gruppen, 0, 8, r, TRUE);
END;
mtUtils.SetState (gruppen, obj, MagicAES.SELECTED, FALSE);
WinDials.WinDialDraw (gruppen, obj, 1, v.r, FALSE);
draw := found;
exit := FALSE;
END cutEntry;
PROCEDURE pasteEntry (obj: INTEGER; env, info: ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
VAR r : GrafBase.Rectangle;
r1, r2 : GrafBase.Rectangle;
x, y : INTEGER;
kstate,
buts : BITSET;
found : BOOLEAN;
index : LONGINT;
adr : GroupSelect.groupPtr;
listInfo : ListMan.LISTINFO;
BEGIN
mtUtils.ObjcArea (gruppen, MausTauschrsc.grcfull, r1);
mtUtils.ObjcArea (gruppen, 0, r2);
MagicAES.GrafMkstate (x, y, buts, kstate);
IF (0 IN buts)
THEN
listInfo := ListMan.LISTINFO (info);
MagicAES.GrafDragbox (r1, r2, x, y);
MagicAES.GrafMkstate (x, y, buts, kstate);
index := ListMan.ListClick (listInfo, x, y, kstate, 0);
(* Persnliche bleiben immer vorne: *)
IF index = 0 THEN INC (index) END;
IF index > 0
THEN
adr := ListMan.ListFindEntry (listInfo, index);
IF adr = NIL
THEN
Lists.AppendEntry (grList, clipEntry, v.bool);
index := VAL (LONGINT, Lists.NoOfEntries (grList));
ELSE
IF index > 1 THEN adr := Lists.PrevEntry (grList); END;
Lists.InsertEntry (grList, clipEntry, v.bool);
END;
(* Jetzt mal schnell alle Eintrge deselektieren *)
Lists.ResetList (grList);
adr := Lists.NextEntry (grList);
WHILE adr # NIL DO
adr^.selected := FALSE;
adr := Lists.NextEntry (grList);
END;
clipEntry^.selected := FALSE;
v.bool := selGrEntry (clipEntry, env, 0);
ListMan.ListScroll2Selection (listInfo, TRUE);
mtUtils.SetFlag (gruppen, MausTauschrsc.grcfull, MagicAES.HIDETREE, TRUE);
mtUtils.SetFlag (gruppen, MausTauschrsc.grcempty, MagicAES.HIDETREE, FALSE);
mtUtils.CalcArea (gruppen, MausTauschrsc.grcempty, r);
WinDials.WinDialDraw (gruppen, 0, 8, r, TRUE);
clipEntry := NIL;
draw := TRUE;
ELSE
draw := FALSE;
END;
ELSE
draw := FALSE;
END;
exit := FALSE;
END pasteEntry;
PROCEDURE clipEmpty (obj: INTEGER; env, info : ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
BEGIN
MTE.InfoAlert (MTE.clipInfo, MTE.clipInfo2, "");
draw := FALSE;
exit := FALSE;
END clipEmpty;
PROCEDURE helpButton (obj: INTEGER; env, info : ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
VAR modePtr : envRecPtr;
topic : CatHelp.tHelp;
BEGIN
modePtr := env;
CASE modePtr^.mode OF
gsmReadBegin,
gsmReadNew,
gsmReadUnread,
gsmReadLastPos,
gsmReadDate,
gsmGroupCom,
gsmReadId : topic := CatHelp.groupRead; |
gsmWrite : topic := CatHelp.groupWrite; |
gsmUser : topic := CatHelp.groupUser; |
gsmChief,
gsmOther,
gsmModify : topic := CatHelp.groupsel; |
ELSE
topic := CatHelp.groupRead;
END;
CatHelp.DoHelp (topic);
mtUtils.ExclState (gruppen, obj, MagicAES.SELECTED);
WinDials.WinDialDraw (gruppen, obj, 1, v.r, FALSE);
draw := FALSE;
exit := FALSE;
END helpButton;
PROCEDURE updateButton (entry, env : ADDRESS);
VAR oneSel : BOOLEAN;
gr : GroupSelect.groupPtr;
modePtr: envRecPtr;
BEGIN
modePtr := env;
Lists.ResetList (grList);
Lists.ScanEntries (grList, Lists.forward, findSel, NIL, oneSel);
oneSel := oneSel & (clipEntry = NIL);
IF oneSel
THEN
gr := Lists.CurrentEntry (grList);
oneSel := oneSel & (gr^.catNumber # dataSys.private);
END;
IF (oneSel & (mtUtils.InState (gruppen, MausTauschrsc.gdelete, MagicAES.DISABLED) OR
mtUtils.InState (gruppen, MausTauschrsc.gchange, MagicAES.DISABLED)))
OR (~oneSel & (~mtUtils.InState (gruppen, MausTauschrsc.gdelete, MagicAES.DISABLED)
OR ~mtUtils.InState (gruppen, MausTauschrsc.gchange, MagicAES.DISABLED)))
THEN
mtUtils.SetState (gruppen, MausTauschrsc.gdelete, MagicAES.DISABLED, ~oneSel);
WinDials.WinDialDraw (gruppen, MausTauschrsc.gdelete, 0, v.r, FALSE);
mtUtils.SetState (gruppen, MausTauschrsc.gchange, MagicAES.DISABLED, ~oneSel);
WinDials.WinDialDraw (gruppen, MausTauschrsc.gchange, 0, v.r, FALSE);
END;
oneSel := (clipEntry = NIL);
IF (oneSel & mtUtils.InState (gruppen, MausTauschrsc.gok, MagicAES.DISABLED))
OR (~oneSel & ~mtUtils.InState (gruppen, MausTauschrsc.gok, MagicAES.DISABLED))
THEN
mtUtils.SetState (gruppen, MausTauschrsc.gok, MagicAES.DISABLED, ~oneSel);
WinDials.WinDialDraw (gruppen, MausTauschrsc.gok, 0, v.r, FALSE);
mtUtils.SetFlag (gruppen, MausTauschrsc.gok, MagicAES.DEFAULT, oneSel);
END;
END updateButton;
PROCEDURE allSelected (obj: INTEGER; env, info: ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
BEGIN
mtUtils.SetObjcString (gruppen, MausTauschrsc.newgroup, "");
WinDials.WinDialDraw (gruppen, MausTauschrsc.newgroup, 0, v.r, FALSE);
draw := FALSE;
exit := TRUE;
END allSelected;
PROCEDURE sortGroupList (obj: INTEGER; env, info: ADDRESS; VAR draw, exit: BOOLEAN);
BEGIN
GroupSelect.DeleteList (grList);
v.bool := GroupSelect.GetReadList (grList, FALSE, FALSE, FALSE);
mtUtils.ExclState (gruppen, obj, MagicAES.SELECTED);
WinDials.WinDialDraw (gruppen, obj, 1, v.r, FALSE);
draw := TRUE;
exit := FALSE;
END sortGroupList;
PROCEDURE switchWriteList (obj: INTEGER; env, info: ADDRESS; VAR draw, exit: BOOLEAN);
BEGIN
GroupSelect.DeleteList (grList);
IF mtUtils.InState (gruppen, obj, MagicAES.SELECTED)
THEN
v.bool := GroupSelect.GetWriteList (grList, TRUE);
v.bool := ConfVars.SetConfigBool (cSmallWriteList, FALSE);
ELSE
(* Nur kleine Liste holen *)
v.bool := GroupSelect.GetWriteList (grList, FALSE);
v.bool := ConfVars.SetConfigBool (cSmallWriteList, TRUE);
END;
draw := TRUE;
exit := FALSE;
END switchWriteList;
PROCEDURE changeGroup (obj: INTEGER; env, info: ADDRESS; VAR draw, exit: BOOLEAN);
CONST cTitel = 'Gruppe umbenennen';
cPreStr = 'nach:';
VAR wegen: ADDRESS;
oldGruppe: ARRAY [0..255] OF CHAR;
gruppe: ARRAY [0..255] OF CHAR;
optStr: ARRAY [0..50] OF CHAR;
preStr: ARRAY [0..20] OF CHAR;
oneSel: BOOLEAN;
but : INTEGER;
ok : BOOLEAN;
gr : GroupSelect.groupPtr;
BEGIN
draw := FALSE;
wegen := MausTauschrsc.TreeAddr^[MausTauschrsc.wegen];
Lists.ResetList (grList);
Lists.ScanEntries (grList, Lists.forward, findSel, NIL, oneSel);
IF oneSel
THEN
gr := Lists.CurrentEntry (grList);
MagicStrings.Assign (gr^.name^, gruppe);
MagicStrings.Assign (gr^.name^, oldGruppe);
optStr := cTitel;
preStr := cPreStr;
mtUtils.SetObjcStringAdr (wegen, MausTauschrsc.wgruppe, ADR(oldGruppe));
mtUtils.SetObjcStringAdr (wegen, MausTauschrsc.optstr, ADR(optStr));
mtUtils.SetObjcStringAdr (wegen, MausTauschrsc.prestr, ADR(preStr));
mtUtils.SetObjcString (wegen, MausTauschrsc.wegenstr, "");
REPEAT
but := FormHandle (wegen);
draw := but # MausTauschrsc.wegcanc;
ok := TRUE;
IF draw
THEN
mtUtils.ObjcString (wegen, MausTauschrsc.wegenstr, gruppe);
IF gruppe[0] = 0C
THEN
MTE.info (MTE.emptyGroup);
ok := FALSE;
ELSIF GroupSelect.GroupNumber (gruppe, v.card)
THEN
MTE.info (MTE.doubleGroup);
ok := FALSE;
ELSE
IF ~GroupSelect.RenameGroup (gr^.name^, gruppe, TRUE)
THEN
MTE.info (MTE.noRenGroup);
ELSE
GroupSelect.DeleteList (grList);
v.bool := GroupSelect.GetReadList (grList, TRUE, FALSE, FALSE);
END;
END;
END;
UNTIL ok;
END;
mtUtils.ExclState (gruppen, obj, MagicAES.SELECTED);
WinDials.WinDialDraw (gruppen, obj, 1, v.r, FALSE);
exit := FALSE;
END changeGroup;
(* List-Zwischen-Prozeduren *)
PROCEDURE groupIsSelected (entry, env : ADDRESS) : BOOLEAN;
VAR ent : GroupSelect.groupPtr;
BEGIN
ent := entry;
RETURN ent^.selected;
END groupIsSelected;
PROCEDURE nameIsSelected (entry, env : ADDRESS) : BOOLEAN;
VAR ent : data.listEntryPtr;
BEGIN
ent := data.listEntryPtr (entry);
RETURN ent^.selected;
END nameIsSelected;
PROCEDURE nextEntry ( l : ADDRESS) : ADDRESS;
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
RETURN Lists.NextEntry (lp^);
END nextEntry;
PROCEDURE prevEntry ( l : ADDRESS) : ADDRESS;
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
RETURN Lists.PrevEntry (lp^)
END prevEntry;
PROCEDURE countEntries ( l : ADDRESS; VAR ll: LONGINT; VAR ww: INTEGER);
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
ww := globalLength*mtAppl.CharWidth;
ll := VAL (LONGINT, Lists.NoOfEntries (lp^));
END countEntries;
PROCEDURE resetList (l : ADDRESS);
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
Lists.ResetList (lp^);
END resetList;
PROCEDURE isEnabled (adr : ADDRESS; env : ADDRESS) : BOOLEAN;
BEGIN
RETURN TRUE
END isEnabled;
VAR tr : mtUtils.tObjcTree;
PROCEDURE drawGroupEntry (entry, env : ADDRESS; x, y : INTEGER;
offset : INTEGER; clip : GrafBase.Rectangle);
CONST spaceString = " ";
VAR e : GroupSelect.groupPtr;
str : ARRAY [0..255] OF CHAR;
BEGIN
e := entry;
tr^[0].obX := x;
tr^[0].obY := y;
tr^[0].obSpec.TedPtr^.teTxtlen := globalLength;
tr^[0].obWidth := globalLength*mtAppl.CharWidth;
IF e # NIL
THEN
(* Jetzt hier den String fr den Gruppennamen zusammenbauen *)
buildGroup (e, env, str);
mtUtils.SetObjcStringAdr (tr, 0, ADR(str));
mtUtils.SetState (tr, 0, MagicAES.SELECTED, groupIsSelected (entry, env));
mtUtils.SetState (tr, 0, MagicAES.DISABLED, ~isEnabled (entry, env));
ELSE
mtUtils.SetObjcStringAdr (tr, 0, CADR(spaceString));
mtUtils.SetState (tr, 0, MagicAES.SELECTED, FALSE);
mtUtils.SetState (tr, 0, MagicAES.DISABLED, FALSE);
END;
MagicAES.ObjcDraw (tr, 0, 8, clip);
END drawGroupEntry;
PROCEDURE setAndGetGroupValues (tree: ADDRESS; private: ADDRESS; set: BOOLEAN; exitBut: INTEGER);
VAR iPtr : envRecPtr;
BEGIN
exitBut := INTEGER(BITSET(exitBut) - {15});
IF set
THEN
ELSE
iPtr := private;
iPtr^.exitBut := exitBut;
END;
END setAndGetGroupValues;
PROCEDURE CheckStr(VAR str : ARRAY OF CHAR):BOOLEAN;
VAR z : CARDINAL;
BEGIN
Strings.DelLeadingBlanks (str);
Strings.DelTrailingBlanks (str);
z := MagicStrings.Length(str);
RETURN z > 0;
(*
z := MagicStrings.Length(str);
IF z > 0 THEN
DEC(z);
WHILE (z > 0) & (str[z] = ' ') DO DEC(z) END;
IF (z = 0) & (str[0] = ' ') THEN str[0] := 0C; RETURN FALSE END;
str[z+1] := 0C;
z := 0;
WHILE (z < HIGH(str)) & (str[z] = ' ') DO INC(z) END;
IF z = HIGH(str) THEN str[0] := 0C; RETURN FALSE END;
IF z > 0 THEN
MagicStrings.Delete(str, 0, z);
END;
RETURN TRUE
ELSE
RETURN FALSE
END;
*)
END CheckStr;
PROCEDURE checkGroupExit (tree: ADDRESS; private: ADDRESS; button: INTEGER;
group: ADDRESS; kState: BITSET): BOOLEAN;
VAR iPtr : envRecPtr;
groupName : ARRAY [0..255] OF CHAR;
GroupOk : BOOLEAN;
BEGIN
iPtr := private;
button := INTEGER(BITSET(button) - {15});
IF (button = MausTauschrsc.gok) THEN
mtUtils.ObjcString (tree, MausTauschrsc.newgroup, groupName);
IF (group = NIL) & (iPtr^.mode # gsmModify) & (iPtr^.mode # gsmUser) & (iPtr^.mode # gsmChief)
THEN
(* Hier noch ndern! *)
IF ~CheckStr(groupName) THEN
MTE.info (MTE.emptyGName);
GroupOk := FALSE;
ELSE (* IF ~nG THEN *)
GroupOk := GroupSelect.GroupNumber(groupName, v.card);
IF ~GroupOk (* & envRec.isReadMode *) THEN
MTE.info (MTE.groupNotFound);
END;
END;
ELSE
GroupOk := TRUE;
END;
IF ~GroupOk
THEN
mtUtils.ExclState(tree, button, MagicAES.SELECTED);
WinDials.WinDialDraw (tree, button, 0, v.r, FALSE);
END;
RETURN GroupOk;
END;
RETURN TRUE;
END checkGroupExit;
(* Gruppenauswahl...*)
PROCEDURE SelectGroup (VAR gruppe : ARRAY OF CHAR; VAR Nr: CARDINAL;
nG : BOOLEAN; clearEdit: BOOLEAN;
forSearch: BOOLEAN; mode: groupSelectMode): BOOLEAN;
VAR exit : INTEGER;
TYPE titleArray = ARRAY groupSelectMode OF ARRAY [0..44] OF CHAR;
CONST titles = titleArray{
'Ab Anfang lesen in Gruppe',
'Neue Nachrichten lesen in Gruppe',
'Ungelesene Nachrichten lesen in Gruppe',
'Ab letzter Position lesen in Gruppe',
'Ab Datum lesen in Gruppe',
'Ab Message-ID lesen in Gruppe',
'Neue Nachricht schreiben in Gruppe',
'User eintragen in Gruppe',
'Gruppe auswhlen',
'Gruppenliste modifizieren',
'Gruppe auswhlen',
'Gruppe auswhlen'};
VAR specials : ARRAY [0..5] OF specialButHdler;
gr,
group : GroupSelect.groupPtr;
found : BOOLEAN;
GroupOk : BOOLEAN;
maxLength: INTEGER;
r : GrafBase.Rectangle;
ilProc : inLoopProc;
whichList: BOOLEAN;
envRec : envRecord;
dialHandler: ListDl.ldHandler;
BEGIN
IF groupDialIsOpen
THEN
RETURN FALSE;
END;
(* Strings setzen *)
mtUtils.SetObjcString (gruppen, MausTauschrsc.gtitel, titles[mode]);
mtUtils.SetFlag (gruppen, MausTauschrsc.gok, MagicAES.DEFAULT, TRUE);
(* Gruppenmodus bestimmen *)
envRec.isReadMode := FALSE;
envRec.mode := mode;
CASE mode OF
gsmReadBegin,
gsmReadNew,
gsmReadUnread,
gsmReadLastPos,
gsmReadDate,
gsmReadId : envRec.isReadMode := TRUE; |
ELSE
END;
mtUtils.SetObjcString (gruppen, MausTauschrsc.gdelete, '[Klemmen');
mtUtils.SetObjcString (gruppen, MausTauschrsc.gchange, '[ndern...');
mtUtils.SetObjcString (gruppen, MausTauschrsc.gball, 'A[lle');
mtUtils.SetFlag (gruppen, MausTauschrsc.gchange, MagicAES.HIDETREE, mode # gsmModify);
mtUtils.SetFlag (gruppen, MausTauschrsc.gdelete, MagicAES.HIDETREE, mode # gsmModify);
mtUtils.SetFlag (gruppen, MausTauschrsc.grcempty, MagicAES.HIDETREE, mode # gsmModify);
(* mtUtils.SetFlag (gruppen, MausTauschrsc.ghelp, MagicAES.HIDETREE, mode # gsmModify); *)
mtUtils.SetFlag (gruppen, MausTauschrsc.grcfull, MagicAES.HIDETREE, TRUE);
mtUtils.SetFlag (gruppen, MausTauschrsc.gball, MagicAES.HIDETREE, (mode # gsmWrite) & (mode # gsmGroupCom) & (mode # gsmModify));
mtUtils.SetFlag (gruppen, MausTauschrsc.gball, MagicAES.Exit, (mode = gsmGroupCom) OR (mode = gsmModify));
mtUtils.SetFlag (gruppen, MausTauschrsc.gball, MagicAES.TOUCHEXIT, mode = gsmWrite);
IF mode = gsmWrite
THEN
(* Nachsehen, welche Liste wir zuerst anfordern *)
ConfVars.GetConfDefBool (cSmallWriteList, whichList, TRUE);
mtUtils.SetState (gruppen, MausTauschrsc.gball, MagicAES.SELECTED, ~whichList);
v.bool := ConfVars.SetConfigBool (cSmallWriteList, whichList);
ELSIF mode = gsmModify
THEN
mtUtils.SetObjcString (gruppen, MausTauschrsc.gball, '[Sort');
mtUtils.SetState (gruppen, MausTauschrsc.gball, MagicAES.SELECTED, FALSE);
END;
found := FALSE;
(* Editfeld lschen *)
IF clearEdit THEN
mtUtils.SetObjcString (gruppen, MausTauschrsc.newgroup, '');
ELSE
mtUtils.SetObjcString (gruppen, MausTauschrsc.newgroup, lastGroup);
END;
(* specials bestimmen *)
specials[0].objc := MausTauschrsc.gdelete;
specials[0].proc := cutEntry;
specials[1].objc := MausTauschrsc.grcfull;
specials[1].proc := pasteEntry;
specials[2].objc := MausTauschrsc.grcempty;
specials[2].proc := clipEmpty;
specials[3].objc := MausTauschrsc.gball;
IF mode = gsmWrite
THEN
specials[3].proc := switchWriteList;
ELSIF mode = gsmModify
THEN
specials[3].proc := sortGroupList;
ELSE
specials[3].proc := allSelected;
END;
specials[4].objc := MausTauschrsc.gchange;
specials[4].proc := changeGroup;
specials[5].objc := MausTauschrsc.ghelp;
specials[5].proc := helpButton;
clipEntry := NIL;
IF ~forSearch
THEN
ilProc := updateButton;
ELSE
ilProc := dummyInLoop;
END;
(* Jetzt die Liste anfordern beim Listenmodul *)
IF (mode = gsmUser) OR (mode = gsmChief)
THEN
v.bool := GroupSelect.GetUserList (grList);
ELSIF (mode = gsmOther)
THEN
v.bool := GroupSelect.GetSelectList (grList, TRUE, GroupSelect.sName);
ELSIF envRec.isReadMode OR forSearch OR (mode = gsmModify)
THEN
v.bool := GroupSelect.GetReadList (grList, TRUE, mode = gsmReadNew, mode = gsmReadUnread);
ELSE
IF mode = gsmWrite
THEN
v.bool := GroupSelect.GetWriteList (grList, ~whichList)
ELSE
v.bool := GroupSelect.GetWriteList (grList, TRUE);
END;
END;
IF ~v.bool THEN RETURN FALSE; END;
(* Maximale Breite eines Listeneintrages herausfinden *)
maxLength := 0;
Lists.ResetList (grList);
group := Lists.NextEntry (grList);
WHILE group # NIL DO
IF INTEGER(LENGTH (group^.name^)) > maxLength
THEN
maxLength := LENGTH (group^.name^);
END;
group := Lists.NextEntry (grList);
END;
INC (maxLength, 9); (* fr neue und ungelesene *)
(* Jetzt das Object zusammenbauen *)
mtUtils.CalcArea (gruppen, MausTauschrsc.groupbox, r);
maxLength := BinOps.HigherInt (maxLength, r.w DIV mtAppl.CharWidth);
globalLength := maxLength;
(* Objectadresse holen *)
tr := MausTauschrsc.TreeAddr^[MausTauschrsc.listtxt];
groupDialIsOpen := TRUE;
(* WindowDialog vorbereiten *)
ListDl.BuildLdHandler (ADR(grList), resetList, nextEntry, prevEntry,
countEntries, isEnabled, selGrEntry,
groupToStr, groupIsSelected, drawGroupEntry,
0, mtAppl.CharHeight,
8, globalLength*mtAppl.CharWidth,
dialHandler);
(* ListWinDialog ffnen *)
IF ListDl.WinListDial (gruppen, ListDl.ldElemSet{ldSelect, ldArrows, ldDoubleExit, ldAutolocate, ldModal},
dialHandler,
MausTauschrsc.groupbox,
MausTauschrsc.groupback,
MausTauschrsc.gok,
MausTauschrsc.gcancel,
ADR(envRec), MausTauschrsc.gok,
MausTauschrsc.newgroup,
ilProc,
specials,
6,
checkGroupExit,
setAndGetGroupValues,
setAndGetGroupValues,
group)
THEN
exit := envRec.exitBut;
IF (exit = MausTauschrsc.gok) & (mode = gsmModify)
THEN
(* Jetzt neue Lesenummern vergeben *)
Lists.ResetList (grList);
maxLength := 0; (* Da Persnliche mit drin ist *)
gr := Lists.NextEntry (grList);
WHILE gr # NIL DO
gr^.readNumber := maxLength;
INC (maxLength);
gr := Lists.NextEntry (grList);
END;
v.bool := GroupSelect.UpdateReadList (grList);
END;
IF exit # MausTauschrsc.gcancel THEN
found := TRUE;
IF (exit = MausTauschrsc.gball) & forSearch THEN
MagicStrings.Assign ("", gruppe);
Nr := $FFFF;
ELSIF exit = MausTauschrsc.gok THEN
IF group = NIL
THEN
mtUtils.ObjcString (gruppen, MausTauschrsc.newgroup, gruppe);
(* Gruppennamen normalisieren *)
v.bool := CheckStr (gruppe);
GroupOk := GroupSelect.GroupNumber(gruppe, Nr);
IF ~GroupOk THEN
IF MagicStrings.Equal(dataSys.personalName, gruppe) THEN
Nr := dataSys.private
ELSIF ~nG
THEN
Nr := dataSys.maxGroup+1; (* darf so nicht bleiben..? *)
found := FALSE;
(* Soll andeuten, da es sich um eine neue, unbekannte Gruppe handelt *)
END; (* sonst ist Nr schon richtig *)
END;
ELSE
MagicStrings.Assign (group^.name^, gruppe);
Nr := CARDINAL(group^.catNumber);
END;
END;
ELSE
found := FALSE
END;
MagicStrings.Assign (gruppe, lastGroup);
ELSE
found := FALSE;
END;
groupDialIsOpen := FALSE;
(* Gruppenliste wieder freigeben *)
GroupSelect.DeleteList (grList);
RETURN found;
END SelectGroup;
(*------------------------------------------------------------------------*)
CONST TAB = 11C;
PROCEDURE getName (REF s1: ARRAY OF CHAR; VAR s2 : ARRAY OF CHAR);
VAR p : INTEGER;
BEGIN
p := Strings.PosLen (TAB, s1, 0);
Strings.Copy (s1, 0, p, s2, v.bool);
END getName;
PROCEDURE getInfo (REF s1: ARRAY OF CHAR; VAR s2 : ARRAY OF CHAR);
VAR p : INTEGER;
BEGIN
p := Strings.Pos (TAB, s1, 0);
IF p >= 0
THEN
Strings.Copy (s1, p+1, INTEGER(LENGTH (s1)) - p - 1, s2, v.bool);
ELSE
Strings.Assign (" ", s2, v.bool);
END;
END getInfo;
PROCEDURE nameToStr (entry, env : ADDRESS; VAR str : ARRAY OF CHAR);
VAR gr : data.listEntryPtr;
BEGIN
gr := data.listEntryPtr (entry);
IF gr = NIL THEN RETURN END;
getName (gr^.gName, str);
END nameToStr;
PROCEDURE selNameEntry (entry, env : ADDRESS; line : INTEGER) : BOOLEAN;
VAR e : data.listEntryPtr;
str : ARRAY [0..255] OF CHAR;
BEGIN
e := data.listEntryPtr (entry);
IF e = NIL THEN RETURN FALSE END;
e^.selected := ~e^.selected;
IF e^.selected & (line >= 0) THEN
getName (e^.gName, str);
mtUtils.SetObjcString(adr, MausTauschrsc.newadr, str);
WinDials.WinDialDraw (adr, MausTauschrsc.newadr, 0, v.r, FALSE);
END;
RETURN FALSE
END selNameEntry;
(*$Z-*)
PROCEDURE findNameSel (e, i : ADDRESS): BOOLEAN;
VAR entry : data.listEntryPtr;
BEGIN
entry := e;
RETURN entry^.selected;
END findNameSel;
PROCEDURE findName (e, i : ADDRESS): BOOLEAN;
VAR entry : data.listEntryPtr;
s1 : ARRAY [0..255] OF CHAR;
s2p : POINTER TO ARRAY [0..255] OF CHAR;
BEGIN
entry := e;
s2p := i;
getName (entry^.gName, s1);
RETURN MagicStrings.Equal (s1, s2p^);
END findName;
(*$Z+*)
TYPE nameInfo = RECORD
entry : data.listEntryPtr;
name,
info : ARRAY [0..255] OF CHAR;
newName : ARRAY [0..255] OF CHAR;
newInfo : ARRAY [0..255] OF CHAR;
inList : BOOLEAN;
exitBut : INTEGER;
END;
nameInfoPtr = POINTER TO nameInfo;
PROCEDURE nameButton (tree: ADDRESS; private: ADDRESS; button: INTEGER;
mx, my : INTEGER; kstate: BITSET; clicks: INTEGER): BOOLEAN;
VAR nInfo : nameInfoPtr;
but : INTEGER;
BEGIN
nInfo := private;
WITH nInfo^ DO
but := INTEGER(BITSET(button) - {15}); (* Doppelclick entfernen *)
mtUtils.ExclState(tree, but, MagicAES.SELECTED);
IF but = MausTauschrsc.nbok
THEN
mtUtils.ObjcString (tree, MausTauschrsc.nbname1, newName);
IF LENGTH (newName) = 0
THEN
MTE.info (MTE.emptyAddr);
WinDials.WinDialDraw (tree, but, 8, v.r, FALSE);
RETURN FALSE
ELSE
RETURN TRUE
END;
END;
END;
RETURN TRUE;
END nameButton;
PROCEDURE nameGetSetValues (tree: ADDRESS; private: ADDRESS;
set: BOOLEAN; exit: INTEGER);
VAR nInfo : nameInfoPtr;
num : CARDINAL;
but : INTEGER;
BEGIN
nInfo := private;
but := INTEGER(BITSET(exit) - {15}); (* Doppelclick entfernen *)
IF set
THEN
WITH nInfo^ DO
(* Nach Namen suchen *)
MagicStrings.Assign (name, newName);
MagicStrings.Assign (info, newInfo);
Lists.ResetList (data.names);
Lists.ScanEntries (data.names, Lists.forward, findName, ADR(name), inList);
IF inList
THEN
entry := Lists.CurrentEntry (data.names);
mtUtils.SetObjcString (tree, MausTauschrsc.nbtitle, 'Adresse ndern');
IF info[0] = ''
THEN
getInfo (entry^.gName, newInfo);
END;
ELSE
mtUtils.SetObjcString (tree, MausTauschrsc.nbtitle, 'Neue Adresse');
END;
mtUtils.SetObjcString (tree, MausTauschrsc.nbname1, newName);
mtUtils.SetObjcString (tree, MausTauschrsc.nbinfo1, newInfo);
END;
ELSE
WITH nInfo^ DO
exitBut := but;
IF but = MausTauschrsc.nbok
THEN
mtUtils.ObjcString (tree, MausTauschrsc.nbinfo1, newInfo);
(* den Namen haben wir schon ausgelesen *)
globalLength := BinOps.HigherInt (globalLength, LENGTH (newName)+1);
globalLength := BinOps.HigherInt (globalLength, LENGTH (newInfo)+3);
Strings.Append (TAB, newName, v.bool);
Strings.Append (newInfo, newName, v.bool);
IF inList
THEN
(* Eintrag ndern *)
Lists.RemoveEntry (data.names, v.bool);
num := entry^.number;
DEALLOCATE (entry, 0);
ALLOCATE (entry, LENGTH (newName) + 7);
IF entry = NIL
THEN
MTE.noMemAlert();
ELSE
WITH entry^ DO
len := LENGTH (newName);
number := num;
selected := TRUE;
Strings.Assign (newName, gName, v.bool);
END;
(* Neuen Eintrag anlegen *)
Lists.InsertEntry (data.names, entry, v.bool);
(* Liste speichern *)
data.SaveNames ();
END;
ELSE
data.AppendName (newName);
END;
END;
END;
END;
END nameGetSetValues;
PROCEDURE NewNameEntry (name, info : ARRAY OF CHAR);
(* Fhrt den Dialog fr einen neuen Namen durch
*)
VAR
tree : mtUtils.tObjcTree;
nInfo : nameInfoPtr;
BEGIN
(* Baumadresse holen *)
tree := MausTauschrsc.TreeAddr^[MausTauschrsc.namebox];
NEW (nInfo);
IF nInfo = NIL
THEN
MTE.noMemAlert();
RETURN
END;
(* Nach Namen suchen *)
MagicStrings.Assign (name, nInfo^.name);
MagicStrings.Assign (info, nInfo^.info);
IF WinDials.OpenWinDial (tree, TRUE,
nameGetSetValues,
nameGetSetValues,
nameButton,
WinDials.defDraw,
"",
nInfo)
THEN
WinDials.WinDialHandleEvents ();
ELSE
MTE.info (MTE.NoWinDial);
END;
DISPOSE (nInfo);
END NewNameEntry;
PROCEDURE newEntry (obj : INTEGER; env, env2: ADDRESS; VAR draw, exit : BOOLEAN);
VAR name,
info : ARRAY [0..255] OF CHAR;
oneSel : BOOLEAN;
entry : data.listEntryPtr;
BEGIN
(* selektieren Eintrag finden *)
Lists.ResetList (data.names);
Lists.ScanEntries (data.names, Lists.forward, findNameSel, NIL, oneSel);
IF oneSel
THEN
entry := Lists.CurrentEntry (data.names);
getName (entry^.gName, name);
getInfo (entry^.gName, info);
ELSE
mtUtils.ObjcString (adr, MausTauschrsc.newadr, name);
Strings.Assign ("", info, v.bool);
END;
NewNameEntry (name, info);
mtUtils.ExclState (adr, obj, MagicAES.SELECTED);
WinDials.WinDialDraw (adr, obj, 0, v.r, FALSE);
draw := TRUE;
exit := FALSE;
END newEntry;
PROCEDURE delEntry (obj : INTEGER; env, info: ADDRESS; VAR draw, exit : BOOLEAN);
VAR oneSel : BOOLEAN;
entry : data.listEntryPtr;
num : CARDINAL;
BEGIN
draw := FALSE;
(* selektieren Eintrag finden *)
Lists.ResetList (data.names);
Lists.ScanEntries (data.names, Lists.forward, findNameSel, NIL, oneSel);
IF oneSel
THEN
v.int := mtAlerts.Alert (1, MTE.delNameAlt);
IF v.int = 1
THEN
entry := Lists.CurrentEntry (data.names);
num := entry^.number;
Lists.RemoveEntry (data.names, v.bool);
Lists.ResetList (data.names);
entry := Lists.NextEntry (data.names);
WHILE entry # NIL DO
IF entry^.number > num
THEN
DEC (entry^.number)
END;
entry := Lists.NextEntry (data.names);
END;
(* Liste jetzt noch speichern *)
data.SaveNames();
draw := TRUE;
END;
END;
mtUtils.ExclState (adr, obj, MagicAES.SELECTED);
WinDials.WinDialDraw (adr, obj, 0, v.r, FALSE);
exit := FALSE;
END delEntry;
VAR isChange : BOOLEAN;
PROCEDURE updateNameButton (entry, env : ADDRESS);
VAR oneSel : BOOLEAN;
BEGIN
Lists.ResetList (data.names);
Lists.ScanEntries (data.names, Lists.forward, findNameSel, NIL, oneSel);
IF (oneSel & mtUtils.InState (adr, MausTauschrsc.deluser, MagicAES.DISABLED))
OR (~oneSel & ~mtUtils.InState (adr, MausTauschrsc.deluser, MagicAES.DISABLED))
THEN
mtUtils.SetState (adr, MausTauschrsc.deluser, MagicAES.DISABLED, ~oneSel);
WinDials.WinDialDraw (adr, MausTauschrsc.deluser, 0, v.r, FALSE);
END;
IF oneSel & ~isChange
THEN
mtUtils.SetObjcString (adr, MausTauschrsc.newuser, '[ndern...');
WinDials.WinDialDraw (adr, MausTauschrsc.newuser, 0, v.r, FALSE);
isChange := TRUE;
ELSIF ~oneSel & isChange
THEN
mtUtils.SetObjcString (adr, MausTauschrsc.newuser, ' [Neu ');
WinDials.WinDialDraw (adr, MausTauschrsc.newuser, 0, v.r, FALSE);
isChange := FALSE;
END;
END updateNameButton;
PROCEDURE drawNameEntry (entry, env : ADDRESS; x, y : INTEGER;
offset : INTEGER; clip : GrafBase.Rectangle);
CONST spaceString = " ";
VAR e : data.listEntryPtr;
str : ARRAY [0..255] OF CHAR;
BEGIN
e := entry;
tr^[0].obX := x;
tr^[0].obY := y;
tr^[0].obSpec.TedPtr^.teTxtlen := globalLength;
tr^[0].obWidth := globalLength*mtAppl.CharWidth;
IF e # NIL
THEN
(* Jetzt hier den String fr den Gruppennamen zusammenbauen *)
getName (e^.gName, str);
mtUtils.SetObjcStringAdr (tr, 0, ADR(str));
mtUtils.SetState (tr, 0, MagicAES.SELECTED, nameIsSelected (entry, env));
mtUtils.SetState (tr, 0, MagicAES.DISABLED, ~isEnabled (entry, env));
MagicAES.ObjcDraw (tr, 0, 8, clip);
INC (tr^[0].obY, mtAppl.CharHeight);
getInfo (e^.gName, str);
MagicStrings.Insert (" ", str, 0);
ELSE
mtUtils.SetObjcStringAdr (tr, 0, CADR(spaceString));
mtUtils.SetState (tr, 0, MagicAES.SELECTED, FALSE);
mtUtils.SetState (tr, 0, MagicAES.DISABLED, FALSE);
MagicAES.ObjcDraw (tr, 0, 8, clip);
INC (tr^[0].obY, mtAppl.CharHeight);
END;
MagicAES.ObjcDraw (tr, 0, 8, clip);
END drawNameEntry;
PROCEDURE setAndGetNameValues (tree: ADDRESS; private: ADDRESS; set: BOOLEAN; exitBut: INTEGER);
VAR iPtr : POINTER TO INTEGER;
BEGIN
IF set
THEN
ELSE
iPtr := private;
iPtr^ := exitBut;
END;
END setAndGetNameValues;
PROCEDURE SelectName(VAR Name : ARRAY OF CHAR):BOOLEAN;
VAR exit : INTEGER;
strPtr : POINTER TO ARRAY [0..255] OF CHAR;
specials : ARRAY [0..1] OF specialButHdler;
selAdr : data.listEntryPtr;
maxLength: INTEGER;
r : GrafBase.Rectangle;
str : ARRAY [0..255] OF CHAR;
dialHandler: ListDl.ldHandler;
name : ARRAY [0..255] OF CHAR;
BEGIN
IF nameDialIsOpen
THEN
RETURN FALSE;
END;
mtUtils.SetObjcString (adr, MausTauschrsc.newadr, Name);
mtUtils.SetObjcString (adr, MausTauschrsc.newuser, ' [Neu ');
isChange := FALSE;
(* Maximale Breite eines Listeneintrages herausfinden *)
maxLength := 0;
Lists.ResetList (data.names);
selAdr := Lists.NextEntry (data.names);
WHILE selAdr # NIL DO
selAdr^.selected := FALSE;
getName (selAdr^.gName, str);
IF INTEGER(LENGTH (str)+1) > maxLength
THEN
maxLength := LENGTH (str)+1;
END;
getInfo (selAdr^.gName, str);
IF INTEGER(LENGTH (str)+3) > maxLength
THEN
maxLength := LENGTH (str)+3;
END;
selAdr := Lists.NextEntry (data.names);
END;
(* Jetzt das Object zusammenbauen *)
mtUtils.CalcArea (adr, MausTauschrsc.adrbox, r);
maxLength := BinOps.HigherInt (maxLength, r.w DIV mtAppl.CharWidth);
globalLength := maxLength;
(* Objectadresse holen *)
tr := MausTauschrsc.TreeAddr^[MausTauschrsc.listtxt];
(* specials bestimmen *)
specials[0].objc := MausTauschrsc.newuser;
specials[0].proc := newEntry;
specials[1].objc := MausTauschrsc.deluser;
specials[1].proc := delEntry;
nameDialIsOpen := TRUE;
(* WindowDialog vorbereiten *)
ListDl.BuildLdHandler (ADR(data.names), resetList, nextEntry, prevEntry,
countEntries, isEnabled, selNameEntry,
nameToStr, nameIsSelected, drawNameEntry,
0, 2*mtAppl.CharHeight,
8, globalLength*mtAppl.CharWidth,
dialHandler);
(* ListWinDialog ffnen *)
IF ListDl.WinListDial (adr, ListDl.ldElemSet{ldSelect, ldArrows, ldDoubleExit, ldAutolocate, ldModal},
dialHandler,
MausTauschrsc.adrbox,
MausTauschrsc.adrback,
MausTauschrsc.adrok,
MausTauschrsc.adrcance,
ADR(exit), MausTauschrsc.adrok,
MausTauschrsc.newadr,
updateNameButton,
specials,
2,
ListDl.dummyCheckExit,
setAndGetNameValues,
setAndGetNameValues,
v.a)
THEN
nameDialIsOpen := FALSE;
mtUtils.ObjcString (adr, MausTauschrsc.newadr, name);
IF (exit = MausTauschrsc.adrok) & (name[0] = 0C) THEN
RETURN FALSE;
END;
IF exit # MausTauschrsc.adrcance THEN
MagicStrings.Assign(name, Name);
RETURN TRUE
END;
END;
nameDialIsOpen := FALSE;
RETURN FALSE
END SelectName;
PROCEDURE SetLastGroup (REF name : ARRAY OF CHAR);
BEGIN
MagicStrings.Assign (name, lastGroup);
END SetLastGroup;
PROCEDURE Init(g, a : ADDRESS);
(* Objektbume fr die Gruppenauswahl- und die Adressenauswahlbox *)
BEGIN
gruppen := g;
adr := a;
END Init;
BEGIN
groupDialIsOpen := FALSE;
nameDialIsOpen := FALSE;
END ListHelp.